package com.changgou.page.listener;

import com.changgou.page.service.PageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 生成商品详情静态页的MQ消费者监听器
 */
@Component
public class CreatePageListener {

    @Autowired
    private PageService pageService;

    private Logger logger = LoggerFactory.getLogger(getClass());

    @RabbitListener(queues = "page_create_queue")
    public void msgHandle(String spuId){
        logger.info("生成商品详情页的MQ监听器，监听到spuId:{}",spuId);
        pageService.createPageHtml(spuId);
        logger.info("根据{}生成静态页面完成",spuId);
    }
}
